﻿Imports Sy.Data
Namespace Client.Export
    Public Class GetClient
        Inherits AbsApi
        Public Overrides ReadOnly Property Action As String
            Get
                Return "client/export/customer"
            End Get
        End Property
        Private ReadOnly Data As Request
        Public Sub New(ID As List(Of Integer))
            Data = New Request(ID)
        End Sub
        Public Response As List(Of Response)
        Public Function [Get](UILog As LogSub) As Boolean
            Dim Log = GetLoger(UILog)
            If Core.Instance.Invoke(Me, Data, Log) = TryResult.Success Then
                Return True
            Else
                Return False
            End If
        End Function
        Public Overrides Function DealSuccess(Result As Integer, Data As String, Log As LogSub) As TryResult
            Response = JsonObject.DeserializeSafety(Of List(Of Response))(Data)
            If Response.IsNotNull AndAlso Response.Count > 0 Then
                Return TryResult.Success
            Else
                Log("JSON解析异常#28")
                Sy.Debug.PrintXHRtoFile("DealSuccess",Data,Action)
                Return TryResult.Fail
            End If
        End Function
        Public Overrides Function Deal(Result As Integer, Data As String, Log As LogSub) As TryResult
            Dim r As Results
            If [Enum].IsDefined(GetType(Results), Result) AndAlso [Enum].TryParse(Result, r) Then
                Log($"{r.GetDescription()}")
            Else
                Log($"Error DataSearch.Search.PostSearch(Result=[{Result}])")
                Return TryResult.ReTry
            End If
            Return TryResult.Fail
        End Function
    End Class
End Namespace
